package com.putable.cgw.world.tests;

import com.putable.cgw.game.Gang;
import com.putable.cgw.game.member.AbstractMember;

import junit.framework.TestCase;

public class TestGang extends TestCase {
	private AbstractMember createConcreteMember(int x, int y){
		return new AbstractMember(){};//Creates an empty anonymous class 
	}
	public void testAdd(){
		Gang g = new Gang();
		for(int i = 0; i < 10; i ++){
			AbstractMember m = createConcreteMember(0,0);
			m.setPosition(0, 0);
			g.add(m);
			assertFalse(g.isEmpty());
			assertTrue(g.size() > 0 );
			g.delete(m);
			assertEquals(0, g.getSize());
		}
		for(int i = 0; i < 10; i ++){
			AbstractMember m = new AbstractMember(){};
			m.setPosition(11, 11);
			g.add(m);
			assertEquals(i+1, g.getSize());
		}
		assertEquals(11, ((AbstractMember)g.getFirst()).getPosition().x);
		assertEquals(10, g.getSize());
	}
	
	public void testDelete(){
		Gang g = new Gang();
		AbstractMember me = createConcreteMember(2,7);
		for(int i = 0; i < 20; i++)
			g.add(new AbstractMember(0,1){});
		g.add(me);
		for(int i = 0; i < 20; i++)
			g.add(new AbstractMember(1,0){});
		
		assertTrue(g.contains(me));
		g.delete(me);
		assertFalse(g.contains(me));
		
	}
}
